package org.example.web;

import org.example.domain.User;
import org.example.feignClient.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 支付服务API
 */
@RestController
public class PayController {

    @Autowired
    private UserFeignClient userFeignClient;

    //浏览器来调用此接口
    @RequestMapping("/pay/{id}")
    public User getUserById(@PathVariable("id") Long id) {
        //使用Feign调用用户服务获取User
        return userFeignClient.getUserById(id);
    }

    //改成get，只是为方便在浏览器中测试
    @GetMapping("/pay/add")
    public User addUser() {
        //先模拟一个user的数据
        User user = new User();
        user.setId(1001L);
        user.setUsername("我是来测feign接口的");
        user.setDesc("测试feignclient");

        return userFeignClient.addUser(user);
    }
}